<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '登录',
  },
}
</route>

<template>
    <view class="title">密码登录</view>
    <item title="手机号" column padding="40rpx 0">
        <wd-input v-model="obj.mobile" placeholder="请输入手机号" clearable />
    </item>
    <item title="密码" column padding="0">
        <wd-input v-model="obj.password" placeholder="请输入密码" clearable show-password />
        <view class="tips">
            <view @click="goHome()"><wd-icon name="arrow-left" size="28rpx" color="#999" />回到首页</view>
            <view></view>
        </view>
    </item>
    <item column padding="0">
        <bottom_button title="登录" :fixed="false" style="margin-top:60rpx;" @click="login()" />
    </item>
</template>

<script lang="ts" setup>
import { http } from '@/utils/http'
import { useStore } from '@/utils/store'
import { goTo } from '@/utils/url'
const store = useStore()
const obj = ref<any>({
    mobile: '',
    password: '',
})
function login() {
    http.post('/member/password_login', obj.value).then((res: any) => {
        uni.showToast({ title: res.message, icon: "none" })
        if (res.code == 200) {
            store.token = res.data
            store.setMemberData()
        }
    })
}

function goHome() {
    goTo('/', true)
}
</script>

<style scoped>
* {
    box-sizing: border-box;
}

page {
    padding: 30rpx;
    background: #fff;
}

.title {
    margin: 50rpx 0 30rpx;
    font-size: 40rpx;
    font-weight: bold;
    text-align: center;
}

.tips {
    display: flex;
    justify-content: space-between;
    margin-top: 20rpx;
    font-size: 28rpx;
    color: #666;
}
</style>